// 需求：计算购物车数据中，被勾选商品的总价
void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": false},
    {"count": 1, "price": 30.0, "selected": false},
    {"count": 5, "price": 20.0, "selected": true}
  ];

  // 1. 定义变量存储总价
  double totalPrice = 0.0;
  // 2. 遍历数组, 完成业务
  for (var i = 0; i < carts.length; i++) {
    var goods = carts[i];
    if (goods['selected']) {
      totalPrice += goods['price'] * goods['count'];
    }
  }
  // 3. 输出结果
  print(totalPrice);
}
